.class final Lcom/trademob/tracking/TMGpsLocationAccess;
.super Ljava/lang/Object;
.source "TMGpsLocationAccess.java"


# instance fields
.field private myContext:Landroid/content/Context;

.field private myLocationManager:Landroid/location/LocationManager;

.field private myTMUtility:Lcom/trademob/tracking/TMUtility;


# direct methods
.method public constructor <init>(Landroid/content/Context;Lcom/trademob/tracking/TMUtility;)V
    .locals 2
    .parameter "aContext"
    .parameter "aTMUtility"

    .prologue
    .line 27
    invoke-direct {p0}, Ljava/lang/Object;-><init>()V

    .line 29
    iput-object p1, p0, Lcom/trademob/tracking/TMGpsLocationAccess;->myContext:Landroid/content/Context;

    .line 30
    iput-object p2, p0, Lcom/trademob/tracking/TMGpsLocationAccess;->myTMUtility:Lcom/trademob/tracking/TMUtility;

    .line 31
    iget-object v0, p0, Lcom/trademob/tracking/TMGpsLocationAccess;->myTMUtility:Lcom/trademob/tracking/TMUtility;

    const-string v1, "android.permission.ACCESS_FINE_LOCATION"

    invoke-virtual {v0, v1}, Lcom/trademob/tracking/TMUtility;->checkPermissionTruly(Ljava/lang/String;)Z

    move-result v0

    if-eqz v0, :cond_0

    invoke-direct {p0}, Lcom/trademob/tracking/TMGpsLocationAccess;->createLocationManager()V

    .line 32
    :cond_0
    return-void
.end method

.method private createLocationManager()V
    .locals 3

    .prologue
    .line 41
    :try_start_0
    iget-object v1, p0, Lcom/trademob/tracking/TMGpsLocationAccess;->myContext:Landroid/content/Context;

    const-string v2, "location"

    invoke-virtual {v1, v2}, Landroid/content/Context;->getSystemService(Ljava/lang/String;)Ljava/lang/Object;

    move-result-object v1

    check-cast v1, Landroid/location/LocationManager;

    iput-object v1, p0, Lcom/trademob/tracking/TMGpsLocationAccess;->myLocationManager:Landroid/location/LocationManager;
    :try_end_0
    .catch Ljava/lang/Exception; {:try_start_0 .. :try_end_0} :catch_0

    .line 48
    :goto_0
    return-void

    .line 43
    :catch_0
    move-exception v0

    .line 46
    .local v0, e:Ljava/lang/Exception;
    invoke-virtual {v0}, Ljava/lang/Exception;->printStackTrace()V

    goto :goto_0
.end method


# virtual methods
.method public final getLocation()Landroid/location/Location;
    .locals 4

    .prologue
    .line 56
    iget-object v2, p0, Lcom/trademob/tracking/TMGpsLocationAccess;->myLocationManager:Landroid/location/LocationManager;

    if-eqz v2, :cond_2

    .line 58
    iget-object v2, p0, Lcom/trademob/tracking/TMGpsLocationAccess;->myLocationManager:Landroid/location/LocationManager;

    const-string v3, "gps"

    invoke-virtual {v2, v3}, Landroid/location/LocationManager;->getLastKnownLocation(Ljava/lang/String;)Landroid/location/Location;

    move-result-object v0

    .line 59
    .local v0, lastKnownGpsLocation:Landroid/location/Location;
    if-eqz v0, :cond_0

    .line 64
    .end local v0           #lastKnownGpsLocation:Landroid/location/Location;
    :goto_0
    return-object v0

    .line 60
    .restart local v0       #lastKnownGpsLocation:Landroid/location/Location;
    :cond_0
    iget-object v2, p0, Lcom/trademob/tracking/TMGpsLocationAccess;->myLocationManager:Landroid/location/LocationManager;

    const-string v3, "network"

    invoke-virtual {v2, v3}, Landroid/location/LocationManager;->getLastKnownLocation(Ljava/lang/String;)Landroid/location/Location;

    move-result-object v1

    .line 61
    .local v1, lastKnownNetworkLocation:Landroid/location/Location;
    if-eqz v1, :cond_1

    move-object v0, v1

    goto :goto_0

    .line 62
    :cond_1
    new-instance v0, Landroid/location/Location;

    .end local v0           #lastKnownGpsLocation:Landroid/location/Location;
    const-string v2, "gps"

    invoke-direct {v0, v2}, Landroid/location/Location;-><init>(Ljava/lang/String;)V

    goto :goto_0

    .line 64
    .end local v1           #lastKnownNetworkLocation:Landroid/location/Location;
    :cond_2
    new-instance v0, Landroid/location/Location;

    const-string v2, ""

    invoke-direct {v0, v2}, Landroid/location/Location;-><init>(Ljava/lang/String;)V

    goto :goto_0
.end method
